//
// Created by Administrator on 2017/12/10.
//

#ifndef EASYPLAYER_MASTER_MYPLAYER_H
#define EASYPLAYER_MASTER_MYPLAYER_H

#endif //EASYPLAYER_MASTER_MYPLAYER_H

#include <string>
#include "../../../../easyplayerlib/src/main/cpp/include/libavformat/avformat.h"

enum PlayerStata {
    UNKNOWN,
    INIT,
    READY,
    BUFFERING,
    PLAYING,
};

class MyPlayer {
public:
    MyPlayer()= default;
    void set_data_source(std::string input_filename);
    void set_event_listener(void (*cb)(int,int,int)){
        event_listener=cb;
    }
    void prepare();
    void play();
    void release();
    bool realtime;
private:
    char* filename;
    void(*event_listener)(int,int,int);
    void read();
    AVFormatContext* ic;
    bool is_realtime();
    int stream_component_open(int);
};